<template>
  <div id="app" class="fillcontain">
    <router-view></router-view>
  </div>
</template>
<script>
import ebus from "../../libs/ebus";
import {api} from '../../libs/api'
import {
  getProductInfo,
  getSystemTime,
  autoFitTime,
  getDiskInfo,
  getNetsInfo,
  getNetsState,
  getAgingStates,
  getTopics
} from "../../store/actions/system";

import {
  getInOutCnt,
  getInputDevInfo,
  getInputChannelInfo,
  getOutputDevInfo,
  getOutputChannelInfo,
  getMulticaseInfo,
  getInputChStreamReport,
  getStremPullInfo,
  getStremPushInfo,
  getAudioOutInfo,
  getLayoutSwitchInfo,
  getStreamSwitchInfo
} from "../../store/actions/media";

import {
  getCCInfo,
} from "../../store/actions/kvm"

export default {
  created() {
    //system
    ebus.on("getProductInfo", getProductInfo);
    ebus.on("getSystemTime", getSystemTime);
    ebus.on("autoFitTime", autoFitTime);
    ebus.on("getDiskInfo", getDiskInfo);
    ebus.on("getNetsInfo", getNetsInfo);
    ebus.on("getNetsState", getNetsState);
    ebus.on("getAgingStates", getAgingStates);
    ebus.on("getTopics", getTopics);

    //media    
    ebus.on("getInOutCnt", getInOutCnt);
    ebus.on("getInputDevInfo", getInputDevInfo);
    ebus.on("getInputChannelInfo", getInputChannelInfo);
    ebus.on("getOutputDevInfo", getOutputDevInfo);
    ebus.on("getOutputChannelInfo", getOutputChannelInfo);
    ebus.on("getMulticaseInfo", getMulticaseInfo);
    ebus.on("getInputChStreamReport", getInputChStreamReport);
    ebus.on("getStremPullInfo", getStremPullInfo);
    ebus.on("getStremPushInfo", getStremPushInfo);
    ebus.on("getAudioOutInfo", getAudioOutInfo);
    ebus.on("getLayoutSwitchInfo", getLayoutSwitchInfo);
    ebus.on("getStreamSwitchInfo", getStreamSwitchInfo);
    
    //kvm    
    ebus.on("getCCInfo", getCCInfo);

    ebus.on('close', ()=>{      
      this.$router.push('/login')
    });
    this.listenMouseAndKeybordEvent();//用户一段时间内不操作就断开连接
  },
  data(){
    return{
      timer: null
    }
  },
  methods:{
    listenMouseAndKeybordEvent(){       
      if(document.addEventListener){
        document.addEventListener('click', this.mouseAndKeybordHander, true);
        document.addEventListener('keyup', this.mouseAndKeybordHander, true);
        document.onmousewheel = this.mouseAndKeybordHander;
      } else{        
        console.error('不支持鼠标键盘监听事件！');        
      }      
    },
    mouseAndKeybordHander(e){
      if(this.timer){
        clearTimeout(this.timer);
      }
      this.timer = setTimeout(() => {
        api.DisConnect();
      }, 10 *  60 * 1000);
    }
    
  }
};
</script>

<style>
#app {
  margin: 0;
  /* height: 939px; */
  height: 100%;
  font-family: "Microsoft Yahei", sans-serif;
  font-style: normal;
  min-width: 1280px; 
  overflow: hidden; 
}
th{
  color:#555;
}
</style>

